package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.activity.MainActivity;
import cn.xfdzx.android.apps.shop.bean.AddressListBeen;
import cn.xfdzx.android.apps.shop.bean.VideoAvatarListBeen;
import cn.xfdzx.android.apps.shop.evenbus.HomeAdressMessage;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;
import cn.xfdzx.android.apps.shop.util.Utils;

import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;

/**
 * Creator: zf.
 * Date: 2019/7/9.
 * Description:视频头像列表适配器.
 */
public class VideoHeadListAdapter extends BaseQuickAdapter<VideoAvatarListBeen, BaseViewHolder>  {
    private OnItemOnClickListener onItemOnClickListener;
    private List<VideoAvatarListBeen> mList;
    public VideoHeadListAdapter(Context mContext,@Nullable List<VideoAvatarListBeen> data) {
        super(R.layout.item_livehead, data);
        this.mContext = mContext;
    }

    @Override
    public void setData(int index, @NonNull VideoAvatarListBeen data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final VideoAvatarListBeen date) {
        //TextView tv_tag = viewHolder.getView(R.id.tv_tag);
        //viewHolder.setText(R.id.tv_name,date.getRealname());
        ImageView imageView = viewHolder.getView(R.id.img_head);
        ImageGlideUtil.loadAvatar(mContext,imageView,date.getHeadUrl());

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onItemOnClickListener.onItemClick();
            }
        });
    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<VideoAvatarListBeen> list){
        this.mList = list;
        super.replaceData(list);
    }

    public void setItemOnClickListener(OnItemOnClickListener listener){
        this.onItemOnClickListener = listener;
    }

    public interface OnItemOnClickListener {
        void onItemClick();
    }

}
